# Makefile
# Author : Edouard ROGE

CC=g++
AR=ar -rcs
CFLAGS= -Wall -Wextra -std=c++11 -fPIC -DCORE_LINUX_EXPORTS
LIBS=-L/usr/local/lib -lpthread 
INCLUDES=-I..

PROJECT=Core
NAME=libcore
SRC_DIR=./
OBJ_DIR=../../obj/$(PROJECT)
LIB_DIR=../../lib
INC_DIR=../../include/$(PROJECT)

SRC_FILES=	Define/Define.cpp \
			Error/Error.cpp \
			Time/TimeMeasure_Linux.cpp \
			Pattern/Singleton.cpp \
			Memory/MemoryPool.cpp \
			Memory/IMemoryManager.cpp \
			Memory/MemoryPoolManager.cpp \
			Memory/HeapObject.cpp \
			Notification/Notification.cpp \
			Notification/NotificationHandler.cpp \
			Notification/NotificationManager.cpp \
			File/URI.cpp \
			File/File.cpp \
			File/DirParser_Linux.cpp \
			File/XMLParser.cpp \
			File/XMLNode.cpp \
			File/XMLTextNode.cpp \
			File/XMLAttribute.cpp \
			File/XMLElement.cpp \
			Log/Logger.cpp \
			Log/LogManager.cpp \
			Log/LogFile.cpp \
			Log/LogConsole.cpp \
			Profile/Profiler.cpp \
			Profile/CodeProfile_Linux.cpp \
			Thread/Thread_Linux.cpp \
			Thread/ThreadLauncher_Linux.cpp \
			Thread/ThreadManager_Linux.cpp \
			Thread/ThreadManager.cpp \
			Thread/ThreadLauncher_Linux.cpp \
			Thread/Thread.cpp \
			Thread/Mutex_Linux.cpp \
			Plugin/Plugin.cpp \
			Plugin/IPlugin_Linux.cpp \
			Plugin/PluginManager.cpp \
			Plugin/PluginObject_Linux.cpp \
			
HDR_FILES=$(addprefix $(SRC_DIR)/, $(SRC_FILES:.cpp=.h))
OBJ_FILES=$(addprefix $(OBJ_DIR)/, $(SRC_FILES:.cpp=.o))

TARGET=$(LIB_DIR)/$(NAME).a

release: CFLAGS += -O3
release:$(TARGET)
debug: CFLAGS += -DDEBUG -g
debug:$(TARGET)
all:$(TARGET)

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cpp
	@echo -n "Compiling `basename $<` : "
	@$(CC) -c $< $(CFLAGS) $(INCLUDES) -o $@
	@cp $(<:.cpp=.h) $(INC_DIR)/$(dir $<)
	@echo "OK"

$(TARGET):$(OBJ_FILES)
	@echo -n "Creating `basename $@` : "
	@$(AR) $(TARGET) $(OBJ_FILES)
	@echo "OK"
	@cp Network/* $(INC_DIR)/Network/
	@cp -r GUI/* $(INC_DIR)/GUI/

clean:
	@echo -n "$(PROJECT) : Deleting .o and library: "
	@rm -f $(OBJ_FILES)
	@rm -f $(TARGET)
	@echo "OK"
